package Week.D008;

import org.junit.Test;

import java.util.HashMap;
import java.util.Map;

public class Solution01 {

    public int countLetters(String S) {
        if(S==null||S.length()==0){
            return 0;
        }
        int result=0;
        int preNum=1;
        char preChar=S.charAt(0);
        for(int i=1;i<S.length();i++){
            char c=S.charAt(i);
            if(c!=preChar){
                result+=((1+preNum)/2.0)*preNum;
                preNum=1;
                preChar=c;
            }else {
                preNum++;
            }

        }
        result+=((1+preNum)/2.0)*preNum;
        return result;
    }
    @Test
    public void test(){
        String path= "aaaaaaaaaa";
        int parentPath=countLetters(path);
        System.out.println(parentPath);
    }
}
